package cn.baage.campus.controller;

import cn.baage.campus.model.vo.UploadFileRspVO;
import cn.baage.campus.service.FileService;
import cn.baage.campus.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;


/**
 * @Description: 文件API
 * @Author: 八阿哥
 * @url: baage.cn
 * @Version: 1.0
 **/
@RestController
@RequestMapping("/file")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@Api(tags = "文件接口")
public class FileController {

    private final FileService fileService;

    @PostMapping("/upload")
    @ApiOperation(value = "文件上传")
    public Result<UploadFileRspVO> uploadFile(@RequestParam MultipartFile file) {
        return Result.success(fileService.uploadFile(file));
    }

}